package servlet;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import model.PageBean;
import model.Student;

import org.omg.CORBA.Request;

import service.Impl.StudentServiceImpl;

public class ServletSearchStu extends HttpServlet{
	
	private Student student;
	private StudentServiceImpl studentServiceImpl=new StudentServiceImpl();

	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		req.setCharacterEncoding("utf-8");
		resp.setContentType("text/html;charset=utf-8");
		
		doPost(req, resp);
		
	}

	@Override
	protected void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		int pageNo=1;
		int pageCount=1;
		String pageNoStr=request.getParameter("pageNo");
		String pageCountStr=request.getParameter("pageCount");
		if(pageNoStr!=null){
			pageNo=Integer.parseInt(pageNoStr);
		}
		if(pageCountStr!=null){
			pageCount=Integer.parseInt(pageCountStr);
		}
		String stuName=request.getParameter("stuName");
		String stuClass=request.getParameter("stuClass");
		String major=request.getParameter("major");
		
		int stuAge=0;
		String stuNum = null;
		String stuSex = null;
		String department = null;
		student=new Student(stuNum, stuName, stuSex, stuAge,
				stuClass, major, department);
		PageBean rs=studentServiceImpl.selectStu(pageNo, pageCount, student);
		request.setAttribute("list", rs);
		request.setAttribute("student", student);
		request.getRequestDispatcher("admin/studentStuInfo.jsp").forward(request, response);
	}

}
